Backport of scaling policy: use request namespace as target if unset in jobspec into release/1.8.x #24096
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport
This PR is auto-generated from #24065 to be assessed for backporting due to the inclusion of the label backport/1.8.x.
🚨
The person who merged in the original PR is:
@tgross
This person should manually cherry-pick the original PR into a new backport PR,
and close this one when the manual backport PR is merged in.
The below text is copied from the body of the original PR.
When jobs are submitted with a scaling policy, the scaling policy's target only includes the job's namespace if the
namespace
field is set in the jobspec and not from the request. Normally jobs are canonicalized in the RPC handler before being written to Raft. But the scaling policy targets are instead written during the conversion fromapi.Job
tostructs.Job
. We populate thestructs.Job
namespace from the request here as well, but only after the conversion has occurred. Swap the order of these operations so that the conversion is always happening with a correct namespace.Long-term we should not be making mutations during conversion either. But we can't remove it immediately because API requests may come from any agent across upgrades. Move the scaling target creation into the
Canonicalize
method and mark it for future removal in the API conversion code path.Fixes: #24039
Note for reviewers: I've broken this into one commit for the immediate fix and one for the
Canonicalize
refactor, just in case we think the latter is too much to land post-beta. I think it's safe, but I'm open to arguments otherwise.Overview of commits